//
//  ViewController.m
//  RDWave
//
//  Created by Mr.Dynasty on 2019/3/12.
//  Copyright © 2019 Mr.Dynasty. All rights reserved.
//

#import "ViewController.h"
#import "MaskLabel/MaskLabel.h"
#import "WaveView/WaveView.h"
@interface ViewController ()

@property (strong, nonatomic) WaveView *waveView;

@property (strong, nonatomic) MaskLabel *maskLabel;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:self.waveView];
    [self addWave];
    [self.view addSubview:self.maskLabel];
}

- (WaveView *)waveView {
    if (!_waveView) {
        _waveView = [[WaveView alloc] initWithFrame:CGRectMake(100, 200, 200, 200)];
        _waveView.layer.cornerRadius = 100;
        _waveView.layer.masksToBounds = YES;
        _waveView.backgroundColor = [UIColor clearColor];
    }
    return _waveView;
}

- (MaskLabel *)maskLabel {
    if (!_maskLabel) {
        _maskLabel = [[MaskLabel alloc] initWithFrame:CGRectMake(100, 200, 200, 200)];
        _maskLabel.font = [UIFont systemFontOfSize:64];
        _maskLabel.textAlignment = NSTextAlignmentCenter;
        _maskLabel.backgroundColor = [UIColor whiteColor];
        _maskLabel.layer.cornerRadius = 100;
        _maskLabel.layer.masksToBounds = YES;
        _maskLabel.text = [NSString stringWithFormat:@"RD"];
        _maskLabel.maskTextEnabled = YES;
    }
    return _maskLabel;
}

- (void)addWave {
    Wave *wave = [Wave defaultWave];
    wave.offsetX = 0;
    wave.offsetY = 100;
    wave.height  = 20;
    wave.width   = 200;
    wave.speedX  = 3;
    wave.fillColor = [UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1].CGColor;
    
    [self.waveView addWave:wave];
    [self.waveView startWaveAnimate];
}

@end
